import Vue from "vue"
import Vuex from "vuex"

Vue.use(Vuex)

import { LANGUAGE } from "@/config/lang"

export default new Vuex.Store({
  state: {
    currentRoute: "",
    language: "",
    languageData: {},
  },
  mutations: {
    setLanguage(state, data) {
      state.language = data
      const languageData = {}
      Object.keys(LANGUAGE).map((key) => {
        languageData[key] = LANGUAGE[key][data]
      })
      state.languageData = languageData
    },
    setCurrentRoute(state, data) {
      console.log("当前路由:::", data.substr(1).replace(/\//g, "_"))
      state.currentRoute = data.substr(1).replace(/\//g, "_")
    },
  },
})
